package z_map;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JInternalFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.HashMap;

public class MapMain extends JFrame {

	MapInput input=null;
	MapUpdate update = null;
	JInternalFrame list = null;
	
	HashMap<String, MapData> map = new HashMap();
	
	private JPanel contentPane;
	private JMenuBar menuBar;
	private JMenu mnFile;
	private JMenuItem mntmInput;
	private JMenuItem mntmUpdate;
	private JMenuItem mntmSearch;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MapMain frame = new MapMain();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MapMain() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 906, 603);
		setJMenuBar(getMenuBar_1());
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
	}

	private JMenuBar getMenuBar_1() {
		if (menuBar == null) {
			menuBar = new JMenuBar();
			menuBar.add(getMnFile());
		}
		return menuBar;
	}
	private JMenu getMnFile() {
		if (mnFile == null) {
			mnFile = new JMenu("자료처리");
			mnFile.add(getMntmInput());
			mnFile.add(getMntmUpdate());
			mnFile.add(getMntmSearch());
		}
		return mnFile;
	}
	private JMenuItem getMntmInput() {
		if (mntmInput == null) {
			mntmInput = new JMenuItem("Input");
			mntmInput.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					if(input == null){
						input = new MapInput(map);
						input.setBounds(0,0,330,250);
					}
					contentPane.add(input);
					input.setVisible(true);
				}
			});
		}
		return mntmInput;
	}
	private JMenuItem getMntmUpdate() {
		if (mntmUpdate == null) {
			mntmUpdate = new JMenuItem("Update");
			mntmUpdate.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					if(update == null){
						update = new MapUpdate(map);
						update.setBounds(0,290,390,270);
					}
					contentPane.add(update);
					update.setVisible(true);
				}
			});
		}
		return mntmUpdate;
	}
	private JMenuItem getMntmSearch() {
		if (mntmSearch == null) {
			mntmSearch = new JMenuItem("List");
			mntmSearch.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					if(list == null){
						list = new MapList2(map);
						list.setBounds(350,0,520,400);
					}
					contentPane.add(list);
					list.setVisible(true);
				}
			});
		}
		return mntmSearch;
	}
}
